<!doctype html>
<html lang="en">
 <head>
  <meta charset="UTF-8">  
  <title>鲜花列表</title>
 </head>
 <body>
 
 <?php
  require_once('inc_admin.php');

  connect();
  //编写sql语句
  $id = $_GET['id'];
  $sql="select * from flower where zqy_id={$id}";
if($_POST['key'])  {
    $key = trim($_POST['key']);
    $sql = $sql." where zqy_title like '%{$key}%' ";
  }

  //echo $sql.'<br/>';  
  $result = fetch_array($sql); 

 ?>

 <center><h3>鲜花查找</h3></center>
 <table align="center" width="80%">
 <tr><td  align="left" >
 <form method=post action="">
    请输入鲜花名：
  <input type="text" name="key">
  <input type="submit" name='search' value="搜索">  
 </form> 
 </td></tr>
 </table>

 <center><h3>鲜花列表</h3></center>
 <table align="center" width="80%" border=1> 
 <tr>
   <th>编号</th>
   <th>鲜花标题</th>   
   <th>鲜花图片</th>
   <th>鲜花产地</th>
   <th>鲜花简介</th>
   <th>添加鲜花的时间</th>
   <th>点击量</th> 
   <th>操作</th>
 </tr>

 <?php
  foreach ($result as $row) {
   echo '<tr>';
   echo '<td>'.$row['zqy_id'].'</td>';
   echo '<td>'.$row['zqy_title'].'</td>'; 
   echo '<td><img src='.UserPhotoPath.$row['zqy_pic'].' width=100 height=90 alt="无图片"></a></td>';
   echo '<td>'.$row['zqy_place'].'</td>';
   echo '<td>'.$row['zqy_intro'].'</td>';
   echo '<td>'.$row['zqy_adddate'].'</td>';
   echo '<td>'.$row['zqy_hint'].'</td>';
   echo '<td><a href="editflower.php?id='.$row['zqy_id'].' ">修改</a> | 
   <a href="delflower.php?id='.$row['zqy_id'].'" onClick="return confirm(\'确定要删除吗？\');">删除</a>| 
   <a href="flowerlist.php?id='.$row['zqy_id'].' ">返回</a></td>';
   echo '</tr>';  
  }
  echo '</table>';  
  $totalrows = count($result);
  echo "<table align='center'><tr><td>共有{$totalrows}种花</td></tr></table>";   
 ?>
 
 </body>
</html>